using System.Reflection;
using System.Text;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using EasyCaching.Core;
using EasyCaching.Core.Configurations;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using Serilog;
using SqlSugar;
using XjjXmm.Infrastructure.Configuration;
using XjjXmm.Infrastructure.Ioc;
using XjjXmm.Infrastructure.ToolKit;

namespace xjjxmm.infrastructure.SetUp;

public static class CacheSetUp
{
	public static WebApplicationBuilder RegistCache(this WebApplicationBuilder builder)
	{
		//引入easy cache
		builder.Services.AddEasyCaching(option =>
		{
			option.UseRedis(ConfigHelper.Configuration, "redis1").WithJson("redis1");
			/*option.UseRedis(config => 
				{
					config.DBConfig.Endpoints.Add(new ServerEndPoint("192.168.88.25", 6379));
				}, "redis1")// using MessagePack to serialize caching data.
				.WithJson("redis1");*/
			//	//with messagepack serialization
			//	;      
		});

		return builder;
	}
}